package com.knowledge.db.mapper;

import com.knowledge.model.pojo.Member;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;

@Mapper
public interface MemberMapper {
    /**
     * @desc 用户注册接口处理
     * @param member
     */
    @Insert("insert into kw_member (username, password, nick_name, avatar, gender, status, create_time, update_time) values (" +
            "#{username},#{password},#{nickName},#{avatar},#{gender},#{status},#{createTime},#{updateTime})")
    void createMember(Member member);

    /**
     * @desc 通过用户名获取用户信息
     * @param username
     * @return
     */
    @Select("select * from kw_member where username=#{username}")
    Member getUserByAccount(String username);

    /**
     * @desc 通过id查询数据信息
     * @param id
     * @return
     */
    @Select("select id, username, nick_name, avatar, gender, status, online from kw_member where id=#{id}")
    Member getUserById(Integer id);

    void updateInfo(Member member);

    /**
     * @desc 查询member列表渲染
     * @return
     */
    @Select("select id, username, nick_name, avatar, gender, status, online from kw_member order by id desc")
    ArrayList<Member> getMemberList();
}
